<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('拜特薪资')"/>
    <th:block th:include="include :: layout-latest-css"/>
    <th:block th:include="include :: ztree-css"/>
    <th:block th:include="include :: container-css"/>
    <th:block th:include="include :: select2-css"/>
    <th:block th:include="include :: bootstrap-select-css"/>
</head>
<body class="white-bg">
<form id="form" class="form-horizontal" AUTOCOMPLETE="OFF">
    <input type="hidden" id="term1" name="term1">
    <div class="modal inmodal fade" id="myModal1" tabindex="-1" role="dialog" aria-hidden="true">
        <div class="modal-dialog modal-sm">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"><span
                            aria-hidden="true">&times;</span><span
                            class="sr-only">Close</span>
                    </button>
                    <h4 class="modal-title">拜特薪资</h4>
                </div>
                <div class="modal-body">
                    <p>
                        薪资套:<select id="pgid" name='pgid' class="form-control noselect2">
                    </select>
                    </p>

                    <p>
                        查询周期:
                        <input id="term" name="term" class="form-control datetimepicker" type="text">
                    </p>

                </div>
                <div class="modal-footer">
                    <button type="button" id="missmodal1" class="btn btn-white" data-dismiss="modal">关闭</button>
                    <button type="button" onclick="getInfo()" class="btn btn-primary">确认</button>
                </div>
            </div>
        </div>
    </div>
    <button type="button" id="modal1" class="btn btn-primary" data-toggle="modal"
            data-target="#myModal1">选择薪资套
    </button>


    <div class="ui-layout-center">
        <div class="container-div">
            <div class="row">
                <div class="col-sm-12 search-collapse">
                    <input type="hidden" id="ComPidorDepTid" name="ComPidorDepTid">
                    <div class="select-list">
                        <ul>
                            <li>
                                工号：<input type="text" name="badge"/>
                            </li>
                            <li>
                                姓名：<input type="text" name="name"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                        class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                        class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </div>
                <div class="btn-group-sm" id="toolbar" role="group">
                    <a class="btn btn-warning" onclick="dataReset()">
                        <i class="fa fa-search"></i> 窗体/窗口输入参数
                    </a>

                    <a class="btn btn-success" onclick="getDataProcedure()">
                        <i class="fa fa-plus"></i> 获取数据
                    </a>
                </div>

                <div class="col-sm-12 select-table table-striped">
                    <table id="bootstrap-table"></table>
                </div>
            </div>
        </div>
    </div>
</form>

<th:block th:include="include :: footer"/>
<th:block th:include="include :: layout-latest-js"/>
<th:block th:include="include :: ztree-js"/>
<th:block th:include="include :: bootstrap-table-editable-js"/>
<th:block th:include="include :: hr-help-js"/>
<th:block th:include="include :: datetimepicker-js"/>
<th:block th:include="include :: select2-js"/>
<th:block th:include="include :: bootstrap-select-js"/>

<script th:inline="javascript">
    var prefix = ctx + "btxz";
    var isInitialization = 0;
    $(function () {
        layui.use('laydate', function () {
            var laydate = layui.laydate;
            laydate.render({
                elem: '.datetimepicker',
                type: 'date'
            });
        });
        $("#modal1").attr("style", "display:none;");
        getSkypayGroups();
    });

    function queryData() {
        isInitialization = 1;
        var options = {
            code: "id",
            uniqueId: "id",
            url: prefix + "/list",
            escape: true,
            showPageGo: true,
            rememberSelected: true,
            height: $(window).height() - 120,
            columns: [{
                checkbox: true
            },
                {
                    field: 'name',
                    title: '姓名'
                },
                {
                    field: 'badge',
                    title: '工号'
                },
                {
                    field: 'yhzh',
                    title: '银行账号'
                },
                {
                    field: 'yhlb',
                    title: '银行类别'
                },
                {
                    field: 'sfgz',
                    title: '实发工资'
                },
                {
                    field: 'yt',
                    title: '用途'
                }, {
                    field: 'sf',
                    title: '省'
                }, {
                    field: 's',
                    title: '市'
                }, {
                    field: 'ylh',
                    title: '银联号'
                }, {
                    field: 'yhmc',
                    title: '银行名称'
                }, {
                    field: 'isth',
                    title: '是否同行'
                }, {
                    field: 'istc',
                    title: '是否同城'
                }]
        };
        $.table.init(options);
    }

    function getDataProcedure() {
        pgid = $("#pgid").val();
        term1 = $("#term1").val();
        $.ajax({
            async: false,
            url: prefix + "/getDataProcedure",
            data: {
                "pgid": pgid, "term": term1
            },
            type: "post",
            dataType: "json",
            success: function (data) {
                if (data.code == 0) {
                    $.modal.alertWarning("操作成功！");
                    $("#bootstrap-table").bootstrapTable("refresh");
                    $(".layui-layer-btn0").click(function () {
                        if (z == 1) {
                            $(".btn-warning", parent.document).click();
                            $.modal.close();
                        }
                    });
                } else if (data.code == 500) {
                    $.modal.alertWarning("服务器繁忙！");
                    $("#bootstrap-table").bootstrapTable("refresh");
                } else {
                    $.modal.alertWarning(data.message);
                    $("#bootstrap-table").bootstrapTable("refresh");
                }

            },
        });

    }

    function getInfo() {
        $("#missmodal1").click();
        pgid = $("#pgid").val();
        term = $("#term").val();
        $("#term1").val(term);
        term1 = $("#term1").val();
        if (pgid != "" && term1 != "") {
            if (isInitialization == 0) {
                queryData();
            } else {
                $.form.reset();
            }
        }
    }

    function dataReset() {
        $("#modal1").click();
    }

    /**
     * 获取薪资套列表
     */
    function getSkypayGroups() {
        var html = "";
        $.ajax({
            async: false,
            url: ctx + "salaryCalculation/getSkypayGroups",
            data: {},
            type: "post",
            dataType: "json",
            success: function (data) {
                $("#pgid").empty();
                var arry = data;
                for (var i = 0; i < arry.length; i++) {
                    html += "<option value='"
                        + arry[i].id
                        + "'>"
                        + arry[i].title
                        + "</option>";
                }
                $("#pgid").append(html);
                $("#modal1").click();
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {

                alert("错误,请联系管理员,错误信息:" + textStatus);
            }
        });
    }

</script>
</body>
</html>